/**
 * 2020-11-27
 * 项目经理获取 打卡信息
 */
'use strict';
const db = uniCloud.database();
const {validateToken} = require("validdate-token");
exports.main = async (event, context) => {
	let {token,projectID,pageNo,pageSize,signinStatus} = event;
	let checkTokenRes;
	try {
		checkTokenRes = await validateToken(token);
		if (checkTokenRes.code !== 0) {
			return {
				status: -1,
				msg: "重新登录",
				errCode: checkTokenRes.errCode
			}
		}
	} catch (e) {
		
	}
	
	let res = await db.collection('signin_store')
	.aggregate()
	.match({
		projectID,
		signinStatus
	})
	.skip((pageNo-1)*pageSize)
	.limit(pageSize)
	.end()
	
	if(res.affectedDocs !== 0 || res.data.length !== 0){
		return {
			status:0,
			msg:"成功",
			data:res.data
		}
	} else {
		return {
			status:1,
			msg:"没有数据"
		}
	}
	
	return {
		status:-1,
		msg:"稍后重试"
	}
};
